package com.hxzy.rabbitmqpublisher.controller;

import com.hxzy.common.ExchangeConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author wy
 * @Description 广播交换机发消息
 * @Date 2024/2/21 16:10
 * @Version 1.0
 */
@RestController
public class FanoutController {

    @Autowired
    private RabbitTemplate  rabbitTemplate;


    @GetMapping(value = "/fanout/send")
    public String sendFanout(String msg){

        for(int i=1;i<=10;i++){
            this.rabbitTemplate.convertAndSend(ExchangeConst.QUEUE_FANOUT_EXCHANGE,"",msg
            +i);
        }

        return "fanout发送成功";
    }
}
